package com.qf.service.Impl;

import com.qf.service.PushSubmitToQueueService;
import com.qianfeng.smsplatform.common.constants.RabbitMqConsants;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
 * @Data: 2021/7/14 19:02
 * */
@Service
public class PushSubmitToQueueServiceImpl implements PushSubmitToQueueService {

    private AmqpTemplate amqpTemplate;
    @Autowired
    public void setAmqpTemplate(AmqpTemplate amqpTemplate) {
        this.amqpTemplate = amqpTemplate;
    }

    @Override
    public void sendSubmitToQueue(List<Standard_Submit> standard_submits) {
//每一个手机号 对应的短信 要一条一条发送  而不是作为一个整体 发送短信 所以此处进行了分拆 拆分后 挨个发送
        standard_submits.forEach(submit->{
            System.out.println("准备发消息");
            System.out.println(submit);
            amqpTemplate.convertAndSend(RabbitMqConsants.TOPIC_PRE_SEND,submit);
        });
    }
}
